package com.anxin.act.task.web;

import com.anxin.act.task.entity.WfPushLog;
import com.anxin.act.task.service.WfPushLogService;
import com.anxin.framework.aspectj.lang.annotation.Log;
import com.anxin.framework.aspectj.lang.enums.BusinessType;
import com.anxin.framework.web.controller.BaseController;
import com.anxin.framework.web.entity.AjaxResult;
import com.anxin.framework.web.page.TableDataInfo;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 流程任务推送记录Controller
 *
 * @author jbs
 * @date 2022-04-13
 */
//@Api(tags = "流程任务推送记录" )
@RestController
@RequestMapping("/log/wfPushLog")
public class WfPushLogController extends BaseController{
    @Autowired
    private WfPushLogService wfPushLogService;

    /**
     * 查询流程任务推送记录列表
     */
    //@ApiOperation(value="查询流程任务推送记录列表" ,notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:wfPushLog:view')")
    @GetMapping("/list")
    @Log(title = "查询流程任务推送记录列表", businessType = BusinessType.LIST)
    public TableDataInfo<List<WfPushLog>> list(WfPushLog wfPushLog){
        startPage();
        List<WfPushLog> list = wfPushLogService.findList(wfPushLog);
        return getDataTable(list);
    }

    /**
     * 获取流程任务推送记录详细信息
     */
    //@ApiOperation(value="获取流程任务推送记录详细信息",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('system:log:view')")
    @GetMapping(value = "/{id}")
    @Log(title = "获取流程任务推送记录详细信息", businessType = BusinessType.LIST)
    public AjaxResult<WfPushLog> getInfo(@PathVariable("id") String id){
        return AjaxResult.success(wfPushLogService.getById(id));
    }

    //@ApiOperation(value="待办任务重新推送",notes="作者:刘翔宇")
    @GetMapping(value = "/againPush/{id}")
    @Log(title = "待办任务重新推送", businessType = BusinessType.OTHER)
    public AjaxResult<WfPushLog> againPush(@PathVariable("id") String id){
        return wfPushLogService.againPush(id);
    }


    //@ApiOperation(value="删除待办推送",notes="作者:刘翔宇")
    @GetMapping(value = "/delTodo/{id}")
    @Log(title = "删除待办推送", businessType = BusinessType.OTHER)
    public AjaxResult<WfPushLog> delTodo(@PathVariable("id") String id){
        wfPushLogService.delTodo(id);
        return AjaxResult.success();
    }

    /**
     * 初始化数据
     * @return
     */
    @GetMapping(value = "/initData")
    public AjaxResult initData(){
        wfPushLogService.initData();
        return AjaxResult.success();
    }
}
